import time
from selenium import webdriver
from selenium.webdriver.common.by import By

dr = webdriver.Chrome()
dr.get("https://movie.douban.com/tv/?support_type=tv&is_all=false&category=tv&type=tv")
dr.maximize_window()
time.sleep(3)
while True:
    try:
        # 点击查看更多
        dr.find_element(By.CSS_SELECTOR, ".subject-list-more button").click()
        time.sleep(2)
    except Exception as e:
        # 如果没能找到加载更多 断开循环
        break
# 找到所有的电视剧
es = dr.find_elements(By.CSS_SELECTOR,".subject-list-list li")
for e in es:
    pic = e.find_element(By.CSS_SELECTOR,".drc-cover-pic")
    title = e.find_element(By.CSS_SELECTOR,".drc-subject-info-title-text").text
    title = title.replace("/","-")
    with open("电视剧/"+title+".png","wb+") as f:
        f.write(pic.screenshot_as_png)
